define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'mall.manager/index',
        add_url: 'mall.manager/add',
        edit_url: 'mall.manager/edit',
        delete_url: 'mall.manager/delete',
        export_url: 'mall.manager/export',
        modify_url: 'mall.manager/modify',
        goods_url:  'mall.goods/index',
        status_url:'mall.manager/statusaction'
    };

    var Controller = {
        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh',
                    [{
                        text: '添加',
                        url: init.add_url,
                        method: 'open',
                        auth: 'add',
                        class: 'layui-btn layui-btn-normal layui-btn-sm',
                        icon: 'fa fa-plus ',
                        extend: 'data-full="true"',
                    }],
                    'export'],
                cols: [[
                    {type: "checkbox"},
                    {field: 'id', width: 80, title: 'ID'},
                    {field: 'title', minWidth: 120, title: '商家名称'},
                    {field: 'realname', minWidth: 100, title: '商家联系人'},
                    {field: 'weixinno', minWidth: 60, title: '微信号'},
                    {field: 'mobile', minWidth: 60, title: '联系电话'},
                    {field: 'servicetel', width: 100, title: '客服电话',search: false},
                    {field: 'address', width: 100, title: '店铺地址',search: false},
                    {field: 'company', width: 100, title: '公司名称',search: false},
                    {field: 'company_tel', width: 100, title: '公司电话',search: false},
                    {field: 'applystatus', width: 100, title: '审核状态',selectList: {0: '待审核', 1: '审核通过',2:'拒绝审核'}},
                    {field: 'status', title: '状态', width: 100, selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
                    {field: 'create_time', minWidth: 80, title: '入驻时间', search: 'range'},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '编辑',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                            },
                            {
                                text: '商家商品',
                                url: init.goods_url,
                                method: 'open',
                                auth: 'goods',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                            },
                            {
                                text: '审核',
                                class: "layui-btn layui-btn-xs layui-btn-normal",
                                extend: 'data-full="true"',
                                auth: 'statusaction',
                                url: init.status_url
                            }],
                            'delete']
                    }
                ]],
            });
            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        statusaction:function (){
            ea.listen();
        }
    };
    return Controller;
});